package Rozklady;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;


public class BorderTest{
	
	public static void main(String[] args) {
	
	// Upper
	JPanel panelA = new JPanel();	
	panelA.setLayout(new FlowLayout(FlowLayout.LEFT));
	for(int i=0; i<3 ; i++){
		panelA.add(new JButton("A"+i));
	}
	
	JPanel panelB = new JPanel();
	panelB.setLayout(new FlowLayout(FlowLayout.RIGHT));	
	for(int i=0; i<3 ; i++){
		panelB.add(new JButton("B"+i)); 
	}
	
	Box upper = Box.createHorizontalBox();
	upper.add(panelA);
	upper.add(Box.createHorizontalGlue());
	upper.add(panelB);
	
	// Center
	JScrollPane scrolPane = new JScrollPane(new JTextArea(50,50));
	scrolPane.setPreferredSize(new Dimension(400,300));
	
	// Bottom
	JPanel numbersKeybord = new JPanel(new GridLayout(3,0,2,2));
	for (int i=1; i<=9 ; i++) numbersKeybord.add(new JButton(""+i));
	numbersKeybord.setMaximumSize(numbersKeybord.getPreferredSize());
	
	JPanel textBottomPanel = new JPanel(new GridLayout(3,0,5,5));
	for (int i=0;i<3 ; i++) {
		JTextField textFieldBottom =new JTextField("To jest JTextField   ");
		textFieldBottom.setBorder(BorderFactory.createLineBorder(Color.red));
		textBottomPanel.add(textFieldBottom);
	}	
	
	Box bottom = Box.createHorizontalBox();
	bottom.add(numbersKeybord);
	bottom.add(Box.createGlue());
	bottom.add(textBottomPanel);
	bottom.add(Box.createGlue());
	
	// Display
	JFrame frame = new JFrame();
	frame.setLayout(new BorderLayout());
	frame.add(upper,"North");
	frame.add(scrolPane,"Center");
	frame.add(bottom,"South");
	frame.setVisible(true);
	frame.setLocationRelativeTo(null);
	frame.pack();
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	//box.add(frame);
		

	}

}
